import { $t } from '#/locales/index.js'
// 课程数据接口
export interface CourseItem {
  id?: number
  name?: string
  instructors?: string
  producer?: string
  summary?: string
  icon?: string
  subjectCategory?: string
  status?: 'listed' | 'unlisted'
  createTime?: string
  lastUpdateTime?: string
  hadDraft?: string
  introduction?: string
  highlights?: string
}

// 过滤表单接口
export interface FilterForm {
  name: string | null
  status: string | null
  subjectCategory?: string
}

export const NODE_TYPE = {
  CHAPTER: 'chapter',
  SUB: 'sub',
  FILE: 'file'
} as const

export const DIALOG_MODE = {
  ADD: 'add',
  EDIT: 'edit'
} as const

export const CONTENT_TYPE = {
  VIDEO: 'video',
  ARTICLE: 'article',
  DOCUMENT: 'document'
} as const

export const CONTENT_TYPE_CONFIG = [
  { value: CONTENT_TYPE.VIDEO, label: $t('course.video', [$t('course.course')]), disabled: false },
  { value: CONTENT_TYPE.ARTICLE, label: $t('course.article', [$t('course.course')]), disabled: true },
  { value: CONTENT_TYPE.DOCUMENT, label: $t('course.document', [$t('course.course')]), disabled: false }
] as const

export type NodeType = typeof NODE_TYPE[keyof typeof NODE_TYPE]
export type DialogMode = typeof DIALOG_MODE[keyof typeof DIALOG_MODE]
export type ContentType = typeof CONTENT_TYPE[keyof typeof CONTENT_TYPE]

export interface TreeNode {
  id?: number | string
  name: string
  type: NodeType
  contentType?: ContentType
  files?: File[]
  children?: TreeNode[]
  content?: TreeNode[] | string
}

export interface CourseInfoApiResponse {
  data: CourseItem[]
  pageInfo: {
    totalRows: number,
    [key: string]: any
  }
}

export const HAD_DRAFT_MAP = {
  YES: 'yes',
  NO: 'no'
} as const


export interface BasicInfoFormData {
  id?: number
  name: string
  instructors: string
  producer: string
  summary: string
  icon?: string
  introduction?: string
  highlights?: string
  subjectCategoryId?: string
  courseCategory?: string
}

export const initBasicInfoFormData: BasicInfoFormData = {
  id: undefined,
  name: '',
  instructors: '',
  producer: '',
  summary: '',
  icon: '',
  introduction: '',
  highlights: '',
  courseCategory: '',
  subjectCategoryId: ''
}
